const toast = str => {
	uni.showToast({
		title: str,
		icon: 'none',
		position: 'bottom',
		duration: 1500
	});
}


//时间戳转换方法    date:时间戳数字
const formatDate = (date) => {
	var date = new Date(date);
	var YY = date.getFullYear() + '-';
	var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
	var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
	var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
	return YY + MM + DD + " " + hh + mm + ss;
}

//uuid 随机生成一段uuid
const guid = () => {
	function S4() {
		return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
	}
	return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4());
}

//过滤null
const filNull = (value,value2='') =>{
  if (value===null) return value2
  else return value
}

//格式化数字
const numberFormat =  (number) => {
    if (!Number(number)) {
        return 0;
    }
    return parseInt(number);
};

module.exports = {
	toast,
	guid,
	formatDate,
	filNull,
	numberFormat
}
